package com.gwnet.shop.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.gwnet.common.log.annotation.Log;
import com.gwnet.common.log.enums.BusinessType;
import com.gwnet.common.mybatis.core.page.TableDataInfo;
import com.gwnet.shop.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gwnet.shop.domain.UserCollectTenant;
import com.gwnet.shop.service.IUserCollectTenantService;

import javax.annotation.Resource;

/**
 * 用户收藏店铺Controller
 * 
 * @author 张万鹏
 * @date 2024-08-01
 */
@RestController
@RequestMapping("/collecttenant")
public class UserCollectTenantController extends MBaseController
{
    @Resource
    private IUserCollectTenantService userCollectTenantService;

    /**
     * 查询用户收藏店铺列表
     */
    @SaCheckPermission("shop:collecttenant:list")
    @GetMapping("/list")
    public TableDataInfo list(UserCollectTenant userCollectTenant)
    {
        startPage();
        List<UserCollectTenant> list = userCollectTenantService.selectUserCollectTenantList(userCollectTenant);
        return getDataTable(list);
    }


    /**
     * 获取用户收藏店铺详细信息
     */
    @SaCheckPermission("shop:collecttenant:query")
    @GetMapping
    public AjaxResult getInfo(UserCollectTenant userCollectTenant)
    {
        return success(userCollectTenantService.selectUserCollectTenantByUserIdAndTenantId(userCollectTenant));
    }

    /**
     * 新增用户收藏店铺
     */
    @SaCheckPermission("shop:collecttenant:add")
    @Log(title = "用户收藏店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserCollectTenant userCollectTenant)
    {
        return toAjax(userCollectTenantService.insertUserCollectTenant(userCollectTenant));
    }


    /**
     * 删除用户收藏店铺
     */
    @SaCheckPermission("shop:collecttenant:remove")
    @Log(title = "用户收藏店铺", businessType = BusinessType.DELETE)
	@DeleteMapping
    public AjaxResult remove(@RequestBody UserCollectTenant userCollectTenant)
    {
        return toAjax(userCollectTenantService.deleteUserCollectTenantByUserIdAndTenantId(userCollectTenant));
    }
}
